|
|
|
|
|
|
|
_Trim(Str(nMax)) + "]:", cName)
' locate rec
If nRec > 0 Then
rs.MoveFirst
For X = 1 To nRec
rs.MoveNext
Next
rs.Edit ' start edit mode
' change rec
If Left(rs.Fields(0), 1) = "X" Then
rs.Fields(0) = Mid(rs.Fields(0), 2, 255)
Else
rs.Fields(0) = "X" + rs.Fields(0)
End If
' tell 'em you changed it
MsgBox "Modified field to: [" + rs.Fields(0) + "]"
' prepare for update mode
cmdEdit.Caption = "&Update"
Me.Caption = cName + " [Rec: " + Trim(Str(X - 1)) + "]"
End If
Else
rs.Update ' attempt update
cmdEdit.Caption = "&Edit" ' fix caption
Me.Caption = cName ' fix header
dbengine.idle dbfreelocks ' pause VB
End If
'
GoTo cmdEditClickExit
'
cmdEditClickErr:
' show error message
MsgBox Trim(Str(Err)) + ": " + Error$, vbCritical, cName + "[cmdEdit]"
'
cmdEditClickExit:
'
End Sub |
|
|
|
|
|
|
|
|
Notice that there is a new line in this routine: the DBEngine.Idle method. This method forces Visual Basic to pause for a moment to update any Dynaset or Snapshot objects that are opened by the program. It is a good idea to place this line in your code so that it is executed during some part of the update process. This ensures that your program has the most recent updates to the dataset. |
|
|
|
|
|
|
|
|
Save the form as MULTIUS2.FRM and the project as MULTIUS2.VBP. Compile the project and save it as MULTIUS2.EXE. Now you're ready to test it. Load two instances of the compiled program. When it starts up, you are prompted for a job name. It does not matter what you enter for the job name, but make sure that you enter different names for each instance. The name you enter is displayed on messages and form headers so that you can tell the two programs apart. Position the two instances apart from each other on the screen. (See Figure 17.5.) |
|
|
|
|
|
|
|
|
First, you'll test the behavior of pessimistic page locking. Make sure that the Pessimistic radio button in the Page Locking frame is selected in both instances of the program. Now click the Edit button of the first instance of the program; when prompted, enter 1 as the record to edit. |
|
|
|
|
|